<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 85167
  Date: 2017/12/10
  Time: 11:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <c:import url="/WEB-INF/page/header.jsp"/>
</head>
<body>
<div class="col-md-12">
    <form id="inputForm" class="form-horizontal" action="${pageContext.request.contextPath}/admin/biz/distributionAccounts/save"
          method="post">
        <input type="hidden" name="id" value="${info.id}">
        <table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
            <tbody>
            <tr>
                <td class="width-15 active"><label class="pull-right"><font color="red">*</font>经销商：</label></td>
                <td class="width-35">
                    <input id="distributorId" name="distributorId" class="form-control required" type="text"
                           value="${distributorId}"
                           aria-required="true">
                </td>
                <td class="width-15 active"><label class="pull-right"><font color="red">*</font>开始时间：</label></td>
                <td id="data_1" class="width-35">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input id="startTime" name="startTime" type="text" class="form-control" value="2019-01-01">
                    </div>
                </td>
            </tr>
            <tr>
                <td class="width-15 active"><label class="pull-right">结束时间 ：</label></td>
                <td id="data_2"  class="width-35">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input id="endTime" name="endTime" type="text" class="form-control" value="2019-01-01">
                    </div>
                </td>
                <td class="width-15 active"><label class="pull-right">分销金额 ：</label></td>
                <td class="width-35">
                    <input id="amount" name="amount" class="form-control required number " type="text"
                           value="0">
                </td>
            </tr>
            </tbody>
        </table>
    </form>
    <button type="button" class="btn btn-white btn-sm"
            onclick="javascript: $('#dataTable').bootstrapTable('refresh');">
        <i class="glyphicon glyphicon-repeat">&nbsp;查询分销记录</i>
    </button>
    <table id="dataTable">
    </table>
</div>
<c:import url="/WEB-INF/page/footer.jsp"/>
<script>

    (function () {
        $('#dataTable').bootstrapTable({
            url: base + "/admin/biz/distributionRecord/list",
            method: "post",
            queryParams: function (params) {
                var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                    limit: 500,   //页面大小
                    offset: 1,  //页码
                    distributorId: $("#distributorId").val(),
                    startTime:$("#startTime").val() + " 00:00:00",
                    endTime:$("#endTime").val() + " 00:00:00",
                    status: 0
                };
                return temp;
            },
            toolbar: '#dataTableToolbar',
            pagination: true,
            sidePagination: "server",
            showFooter:true,
            columns: [{
                checkbox: true
            }, {
                field: 'devId',
                title: '设备ID'
            }, {
                field: 'distributorId',
                title: '经销商ID'
            }, {
                field: 'orderId',
                title: '订单ID'
            }, {
                field: 'orderAmount',
                title: '订单金额'
            }, {
                field: 'amount',
                title: '分销金额'
            }, {
                field: 'createTime',
                title: '创建时间'
            }, {
                field: 'status',
                title: '录入时间',
                formatter: function (value, row, index) {

                    if (value == 1) {
                        return "已结算";
                    } else {
                        return "未结算";
                    }
                },
                footerFormatter:function (data1) {
                    console.log(data1);
                    var count = 0;
                    for (var i in data1) {
                        count += data1[i].amount;
                    }
                    $("#amount").val(count);
                    return 0;
                }
            }]
        });
    })();
    $('#data_1 .input-group.date').datepicker({
        todayBtn: "linked",
        keyboardNavigation: false,
        forceParse: false,
        calendarWeeks: true,
        autoclose: true
    });
    $('#data_2 .input-group.date').datepicker({
        todayBtn: "linked",
        keyboardNavigation: false,
        forceParse: false,
        calendarWeeks: true,
        autoclose: true
    });
</script>
</body>
</html>
